/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.res0w.SMMS.ds;

import com.res0w.SMMS.factory.DataBaseOperate;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author re0w
 * @since 2009-9-22
 * @version 0.2
 */
public class SettingRelay implements BatchSqlInterface {

    public ArrayList relayList = new ArrayList();
    public String itemsName = null;
    public int teamPeopleCount = 0;
    public int sex = 1;
    public int qFinal = 0;
    public int groupNo = 0;

    public String[] exeSqls() {
        String[] sqls = new String[1];
        sqls[0] = "insert into setting_relay values('" + itemsName + "'," +
                "'" + teamPeopleCount + "','" + sex + "'," +
                "'" + qFinal + "','" + groupNo + "')";
        return sqls;
    }

    public void readSqls() {
//        throw new UnsupportedOperationException("Not supported yet.");
        try {
            DataBaseOperate db=new DataBaseOperate();
            ResultSet rs = null;
            String sql = null;
            sql = "select * from setting_relay";
            rs = db.dbQueryMuti(sql);
            while (rs.next()) {
                itemsName = rs.getString(1);
                teamPeopleCount = Integer.parseInt(rs.getString(2));
                sex = Integer.parseInt(rs.getString(3));
                qFinal = Integer.parseInt(rs.getString(4));
                groupNo = Integer.parseInt(rs.getString(5));
                //写入arrayList;
                relayList.add(itemsName);
                relayList.add(teamPeopleCount);
                relayList.add(sex);
                relayList.add(qFinal);
                relayList.add(groupNo);
            }
             db.dbClosed();
        } catch (SQLException ex) {
            Logger.getLogger(SettingRelay.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
